/*
 * @Author: 白川 杏 baiyufeisteam@163.com
 * @Date: 2023-04-12 13:25:21
 * @LastEditors: 白川 杏 baiyufeisteam@163.com
 * @LastEditTime: 2023-04-22 08:32:33
 * @FilePath: \homeworkFinal\koaserver\backend\db.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const mysql = require("mysql");

//创建数据库连接池

let pools = mysql.createPool({
    host:"114.55.42.228",
    user:"herb-garden",
    password:"KZHRn2jXZWNBTbka",
    database:"herb-garden"
})


function excute(sqlString, condition) { // 查询字符串，查询条件
    let promise = new Promise((resolve, reject)=>{
        pools.query(sqlString, condition, function(error, result, fields){
            if(error) {
                reject(error);
            } else{
                resolve(result);
            }
        })
    })
    return promise
}
module.exports = {
    EXCUTE: excute
}